/**
 * 购物车
 * @author [yjc]
 */
const $http = require('../utils/http.js'), api = require('../config/api.js')

/**
 * 加入购物车
 * @params[goodsId]商品id
 * @params[num]商品数量
 * @params[shopId]店铺id
 */
var _saveshopcart = function (params){
  return $http.get(api.GOOD_CART_SET, params)
}

/**
 * 删除购物车
 * @params[cartId]购物车id
 */
var _delcart = function (params) {
  return $http.get(api.GOOD_CART_DEL, params)
}

/**
 * 购物车列表
 */
var _cartlist = function (params) {
  return $http.get(api.GOOD_CART_LIST, params)
}

/**
 * 购物车数量
 */
var _cartnum = function (params) {
  return $http.get(api.GOOD_CART_NUM, params)
}

/**
 * 修改购物车数量
 */
var _changenum = function (params) {
  return $http.get(api.GOOD_CART_CHANGENUM, params)
}

/**
 * 通过经纬度来确定商铺然后对商品的库存进行验证
 * @params[cartIds]购物车Id集合
 * @params[longitude]经度
 * @params[latitude]纬度
 */
var _valid = function (params) {
  return $http.get(api.GOOD_CART_VALID, params)
}

module.exports = {
  saveshopcart: _saveshopcart,
  delcart: _delcart,
  cartlist: _cartlist,
  cartnum: _cartnum,
  changenum: _changenum,
  valid: _valid 
}